package com.shiguiwu.springmybatis.spring.async;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service;

import java.util.concurrent.Future;

/**
 * @description:
 * @author: stone
 * @date: Created by 2021/6/11 18:49
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.springmybatis.spring.async
 */
@Service
@Async
public class AsyncService {

    public void m1() {
        System.out.println("m1.......");
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }

    public Future<String> m2() {
        System.out.println("m2..............");
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        return AsyncResult.forValue("shiguiwu");

    }
}
